//
//  HomeController.swift
//  上海微博
//
//  Created by zhangliming on 16/2/22.
//  Copyright © 2016年 zhangliming. All rights reserved.
//

import UIKit

class HomeController: rooteViewController {

    //重用标示符

    let reuseIndentfier = "homeCell"

    override func viewDidLoad() {
        super.viewDidLoad()

       ///注册cell

        tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: reuseIndentfier)

        ///添加下拉刷新控件

        prepareRefreshControl()

        ///设置访客视图界面信息，和代理

        vistorView?.setUpUI(
            title: "关注一些人，回这里看看有什么惊喜!",
            homeImageName:"visitordiscover_feed_image_house" ,
            wheelImageName: "visitordiscover_feed_image_smallicon")

    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

   }

//MARK:-数据源方法，代理方法

extension HomeController {

   override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return dataList.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCellWithIdentifier(reuseIndentfier)

        cell?.textLabel?.text = dataList[indexPath.row]

        return cell!
    }
    
    override func loadData() {

        dispatch_async(dispatch_get_global_queue(0, 0)) { () -> Void in

            ///获取数据模拟延时

            [NSThread .sleepForTimeInterval(1)]

             self.refreshData()

            dispatch_async(dispatch_get_main_queue(), { () -> Void in

            self.endRefresh()

            })
            
        }
        
    }

}
